//
//  ZMyOrderListShopInfoCell.m
//  DistributorAB
//
//  Created by LZY on 2019/10/14.
//  Copyright © 2019 主事丫环. All rights reserved.
//

#import "ZMyOrderListShopInfoCell.h"
@interface ZMyOrderListShopInfoCell ()
@property (nonatomic, strong) UILabel *lblDate;//日期
@property (nonatomic, strong) UIButton *btnName;//店铺名称
@end

@implementation ZMyOrderListShopInfoCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupViewAction];
    }
    return self;
}
#pragma mark - 界面布局
- (void)setupViewAction{
    self.contentView.backgroundColor = kColorWithHex(0xf2f2f2);
    
    UIView *viewBg = [[UIView alloc] initWithFrame:CGRectMake(0, 10, kScreen_Width, 55)];
    viewBg.backgroundColor = kColorWithHex(0xffffff);
    [self.contentView addSubview:viewBg];
    
    _lblDate = [[UILabel alloc] initWithFrame:CGRectMake(16, 0, kScreen_Width - 32, 35)];
    _lblDate.font = [UIFont systemFontOfSize:12];
    _lblDate.textColor = kColorWithHex(0x999999);
    [viewBg addSubview:_lblDate];
    
    UIImageView *ivShop = [[UIImageView alloc] initWithFrame:CGRectMake(16, 37, 16, 16)];
    ivShop.image = imgname(@"shop_small_green_icon");
    [viewBg addSubview:ivShop];
    
    _btnName = [UIButton buttonWithType:UIButtonTypeCustom];
    [_btnName setTitleColor:kColorWithHex(0x70be68) forState:UIControlStateNormal];
    _btnName.titleLabel.font = [UIFont systemFontOfSize:12];
    [_btnName addTarget:self action:@selector(btnNameClickAction:) forControlEvents:UIControlEventTouchUpInside];
    [viewBg addSubview:_btnName];
    [_btnName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(ivShop.mas_centerY);
        make.leading.equalTo(ivShop.mas_trailing).offset(1);
        make.height.mas_equalTo(20);
    }];
    
    UIImageView *ivArrow = [UIImageView new];
    ivArrow.image = imgname(@"arrow_right_icon");
    [viewBg addSubview:ivArrow];
    [ivArrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(ivShop.mas_centerY);
        make.leading.equalTo(self.btnName.mas_trailing).offset(16);
        make.size.mas_equalTo(CGSizeMake(6, 12));
    }];
    
    
}
#pragma mark - 数据更新
- (void)setOrderModel:(ZMyOrderListOrderModel *)orderModel{
    if (orderModel) {
        _orderModel = orderModel;
        _lblDate.text = orderModel.createTime;
        [_btnName setTitle:orderModel.factory_name forState:UIControlStateNormal];
    }
}
#pragma mark - 交互事件
- (void)btnNameClickAction:(UIButton *)sender{
    if (self.orderModel && self.delegate && [self.delegate respondsToSelector:@selector(shopInfoCellClickWith:)]) {
        [self.delegate shopInfoCellClickWith:self.orderModel];
    }
}
+ (CGFloat)cellHeight{
    return 65.0;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
